﻿using System;
using System.Windows.Data;

namespace Red.Core.Extensions
{
    /// <summary>
    /// Shortcut for creating an Uri pointing to a resource contained in the Red.Resources assembly
    /// </summary>
    public class ResourceUri : Uri
    {
        public ResourceUri( string resourcePath )
            : base( "pack://application:,,,/Red.Resources;component/" + resourcePath )
        { }
    }

    /// <summary>
    /// Markup extension for creating an Uri pointing to a resources contained in the Red.Resources assembly
    /// </summary>
    public class ResourceUriExtension : Binding
    {
        // NOTE: in order to work in a trigger setter this has to be a Binding, not just MarkupExtension
        // (only those are accepted by Setters). It's also much simpler this way.
        public ResourceUriExtension( string path )
        {
            Source = new ResourceUri( path ).ToString();
        }
    }
}
